<?php
	class ItemStack implements JsonSerializable{
		private $item;
		private $qty;

		function __construct(Item $item, $quantity)
		{
			$this->setItem($item);
			if(!is_int($quantity) || $quantity <= 0)
				throw new InvalidArgumentException('Stack size must be >= 1');
			else $this->setQuantity($quantity);
		}

		// Getters / Setters
		function getItem()
		{
			return $this->item;
		}

		private function setItem(Item $newItem)
		{
			$this->item = $newItem;
		}

		function getQuantity()
		{
			return (int)$this->qty;
		}

		private function setQuantity($newQuantity)
		{
			$this->qty = $newQuantity;
		}
		// End Getters / Setters

		// Public Methods
		public function jsonSerialize()
		{
			return [
				'item' => $this->getItem(),
				'quantity' => $this->getQuantity()
			];
		}
		// End Public Methods
	}
?>
